const {multerGoodsConfig}  = require('../multer')
const { upload_config } = require('../../config/upload')

// 图片上传
const image_upload = multerGoodsConfig.fields([{name: 'fileList', maxCount: 5}])

module.exports = function (req, res)  { 
    image_upload(req, res, function(err) {
        if (err) {
         res.sendResult(null, 400, err)
       } else {
          const arr = req.files.fileList.map(i => {
           var obj = {}
           obj.pic = upload_config.baseURL+ '/' + i.destination+ '/'+ i.filename
           return obj
          })
          res.sendResult(arr, 200, '图片上传成功')
       }
     })
}